package client;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.util.List;
import java.util.Map;

import surname.protocol.ListSurnameRequest;

public class Reception 
{
	private Socket socket;
	private ObjectInputStream is;
	
	public Reception(Socket s)
	{
		socket = s;
		try 
		{
			is = new ObjectInputStream(socket.getInputStream());
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
	}
	
	public Map<String, List<String>> get()
	{
		  while(true)
		  {
			  try 
			  {
				ListSurnameRequest list = (ListSurnameRequest) is.readObject();
				return (Map<String, List<String>>)list.getList();
			  } 
			  catch (IOException e) 
			  {
				e.printStackTrace();
			  } 
			  catch (ClassNotFoundException e) 
			  {
				e.printStackTrace();
			  }
		  }
	}
}
